<% title "Create a new topic" %>

<% crumb "Home", index_url %>
<% crumb @category.forum.title, forum_url(@category.forum) %>
<% crumb @category.title, category_url(@category) %>
<% crumb "New topic", new_category_post_url(@category), :class => 'active' %>

<div class="wrapper fl">

  <h2>New topic</h2>

  <div id="preview" style="display:none">
    <span class="small">Preview</span>
    <h3 id="preview-title"><%= h @topic.title %></h3>
    <div id="preview-body">
      <%= @topic.body_html %>
    </div>
  </div>

  <div id="post">
    <% form_for(:topic, :url => category_posts_url(@category), :html => {:id => 'topic-form', :multipart => true}) do |form| %>   
    <dl>
      <dt>
        <label for="topic_title">Topic name</label>
        <span class="hint">title of the new topic</span>
      </dt>
      <dd><%= form.text_field 'title' %></dd>

      <dt>
        <label for="topic_body">Message</label>
      </dt>
      <dd><%= form.text_area 'body', :class => 'less' %></dd>
    </dl>
  
    <div id="more-space"><%= link_to_function 'More space to type &darr;', 'Opinion.toggleTextarea(true)' %></div>
    <div id="less-space" style="display:none"><%= link_to_function 'Less space to type &uarr;', 'Opinion.toggleTextarea(false)' %></div>

    <p>
      <% fields_for :image do |i| %>
      <label for="image_uploaded_data">Attach an image:</label>  <%= i.file_field :uploaded_data %>
      <% end %>
    </p>
    
    <p>
      <%= submit_tag 'Create', :disable_with => 'Creating topic&hellip;' %> or <%= link_to_function 'Preview', "$('preview-title').innerHTML = $('topic_title').value;new Ajax.Updater('preview-body','/preview_textile', {postBody: $F('topic_body') });$('preview').show()" %> or <%= link_to 'Cancel', category_url(@category) %>
    </p>
    
    <% end %>

  </div>
  
</div>


<div id="sidebar" style="margin-left: 620px;padding-top: 110px"> 
  <div id="formatting-guide" style="background: #fff">
    <%= render :partial => 'formatting_guide' %>
  </div>
</div>

<div class="clear"> </div>